#include "table.h"
#include <algorithm>//for std::swap
Table::Table():m_Vec()
{
}
Table::Table(const Table& table)
{
    this->m_Vec = table.m_Vec;
}
Table::~Table()
{
}
Table& Table::operator=(const Table& table)
{
    this->m_Vec = table.m_Vec;
    return *this;
}
const int& Table::operator[](const std::string& str)const
{
    typedef std::vector<Pair>::const_iterator CI;
    for(CI ci = m_Vec.begin(); ci != m_Vec.end(); ci++){
        if(ci->str == str){
            return ci->data;
        }
    }
    throw Bad_op();
}
int& Table::operator[](const std::string& str)
{
    typedef std::vector<Pair>::iterator IT;
    for(IT it = m_Vec.begin(); it != m_Vec.end(); it++){
        if(it->str == str){
            return it->data;
        }
    }
    Pair p;
    p.str = str;
    m_Vec.push_back(p);
    return (m_Vec.end()-1)->data;
}



    
    
